using UnityEngine;

public class LikeModeButton : MonoBehaviour
{
	[SerializeField]
	private GameObject selectedButton;

	[SerializeField]
	private GameObject unselectedButton;

	private bool _status;

	private GameTypePreviewInLeaderBoard _gameTypePreviewInLeaderBoard;

	private SelectableButtonMode _buttonMode;

	public bool Status
	{
		get
		{
			return _status;
		}
		set
		{
			_status = value;
		}
	}

	public GameTypePreviewInLeaderBoard GameTypePreviewInLeaderBoard
	{
		get
		{
			return _gameTypePreviewInLeaderBoard;
		}
		set
		{
			_gameTypePreviewInLeaderBoard = value;
		}
	}

	public SelectableButtonMode ButtonMode
	{
		get
		{
			return _buttonMode;
		}
		set
		{
			_buttonMode = value;
			Status = LikeModeManager.instance.GetLikeStatus(_buttonMode.ModeInfo.typeGame);
		}
	}

	public void RefreshView()
	{
		selectedButton.SetActive(Status);
		unselectedButton.SetActive(!Status);
	}

	public void RefreshStatus()
	{
		Status = LikeModeManager.instance.GetLikeStatus(ButtonMode.ModeInfo.typeGame);
	}

	private void OnClick()
	{
		Status = !Status;
		LikeModeManager.instance.SetLikeStatus(ButtonMode.ModeInfo.typeGame, Status);
		RefreshView();
		ButtonMode.RefresfViewLikeBox();
		ButtonMode.ModifyPercent(Status ? 1 : (-1));
		if ((bool)_gameTypePreviewInLeaderBoard)
		{
			_gameTypePreviewInLeaderBoard.RefresfViewLikeBox();
			_gameTypePreviewInLeaderBoard.ModifyPercent(Status ? 1 : (-1));
		}
	}
}
